#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

bool isZs(int num){
	
	for(int i=2;i<=sqrt(num);++i){
		if(num%i==0){
			return false;
		}
	}
	return true;
}
bool check(int num){
	vector<int> vecArr;
	
	while(num){
		vecArr.push_back(num%10);
		num/=10;
	}
	for(int i=0;i<static_cast<int>(vecArr.size());++i){
		for(int j=0;j<static_cast<int>(vecArr.size());++j){
			if(vecArr[i]==0 || i==j){
				continue;
			}
			if(isZs(vecArr[i]*10+vecArr[j])){
				
				return true;
			}
		}
	}
	
	return false;
}
int main() {

	int a,b;
	int cnt=0;
	cin>>a>>b;
	for(int i=a;i<=b;++i){
		if(check(i)){
			++cnt;
		}
	}
	cout<<cnt<<endl;
	
	return 0;
}
